package xyz.qq66179820.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @author lihj
 * @date 2022/1/23
 */
@RestController
@Slf4j
public class PaymentConsumerController {

    @Autowired
//    @Resource
    private RestTemplate restTemplate;

    @Value("${service-url.nacos-user-service}")
    private String serviceUrl;

    @GetMapping("/consumer/{id}")
    public String getX(@PathVariable String id) {
        String url = serviceUrl + "/pay/" + id;
        log.info("url:" + url);

        return restTemplate.getForObject(url, String.class);

    }
}
